{include file="common/head_exit"}
<script src="/meetTWO/public/static/release/jquery-1.11.2.js" type="text/javascript"></script>
<script src="/meetTWO/public/static/release/eit.js"></script>

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>遇见冬奥</title>
    <style type="text/css">
    </style>
</head>
<style>
    html {
        font-family: "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", "宋体", Arial, Verdana, sans-serif;
        -ms-text-size-adjust: 100%;
        -webkit-text-size-adjust: 100%;
        font-size: 62.5%;
    }

    body {
        font-size: 1.4rem;
    }

    html,
    body,
    div,
    p {
        margin: 0;
        padding: 0;
        border: 0;
        vertical-align: baseline;
        font-weight: normal;
    }

    a {
        background: transparent;
    }

    a:active,
    a:hover {
        outline: 0;
    }

    img {
        border: 0;
    }

    button,
    input,
    optgroup,
    select,
    textarea {
        color: inherit;
        font: inherit;
        margin: 0;
    }

    button {
        overflow: visible;
    }

    button,
    select {
        text-transform: none;
    }

    button,
    html input[type="button"],
    input[type="reset"],
    input[type="submit"] {
        -webkit-appearance: button;
        cursor: pointer;
    }

    button[disabled],
    html input[disabled] {
        cursor: default;
    }

    button::-moz-focus-inner,
    input::-moz-focus-inner {
        border: 0;
        padding: 0;
    }

    input {
        line-height: normal;
    }

    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }

    body {
        background: #ededed;
        color: #666666;
        line-height: 20px;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
    }

    body.white {
        background: #ffffff;
    }

    html.hairlines div,
    html.hairlines li,
    html.hairlines a,
    html.hairlines i,
    html.hairlines header {
        border-width: 0.5px !important;
    }

    html .g-image-upload-box .upload-btn {
        border: 1px dashed #e3e3e3 !important;
    }

    a {
        color: #3278ee;
        text-decoration: none;
    }

    input[type="text"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    textarea {
        border: none;
        font-size: 1.4rem;
        height: 20px;
        line-height: 20px;
        padding: 5px;
        color: #333333;
        font-family: "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", "宋体", Arial, Verdana, sans-serif;
        outline: none;
        -webkit-border-radius: none;
        -moz-border-radius: none;
        border-radius: none;
    }

    textarea {
        outline: none;
        border: none;
        resize: none;
        height: 90px;
        width: 100%;
        box-sizing: border-box;
        -moz-box-sizing: border-box;
        /* Firefox */
        -webkit-box-sizing: border-box;
        /* Safari */
    }

    input[type=text]:active,
    input[type=password]:active,
    textarea:active,
    input[type=text]:focus,
    input[type=password]:focus,
    textarea:focus {
        border: none;
        background: #ffffff;
        outline: none;
    }

    ::-webkit-input-placeholder {
        -webkit-text-fill-color: #bdbdbd;
    }

    ::-moz-placeholder {
        color: #dddddd;
    }

    input:-ms-input-placeholder {
        color: #dddddd;
    }

    textarea:-ms-input-placeholder {
        color: #dddddd;
    }

    .publish-article-title {
        padding: 15px;
        background: #fff;
        margin-bottom: 10px;
        border: 1px solid #ccc;
    }

    .title-tips {
        font-weight: bold;
        margin-bottom: 3px;
    }

    .publish-article-content {
        padding: 15px;
        background: #fff;
        border: 1px solid #ccc;
    }

    .publish-article-content .article-content {
        height: 350px;
        border-bottom: 1px solid #ccc;
    }

    .publish-article-content .footer-btn {
        text-align: center;
        padding-top: 10px;
    }

    .publish-article-content .footer-btn .upload-img {
        display: inline-block;
        vertical-align: bottom;
        width: 25px;
        height: 20px;
        margin-right: 10px;
        background: url(/meetTWO/public/static/images/img.png) 0 no-repeat;
        background-size: 100%;
    }

    .up_btn {
        position: absolute;
        z-index: 999;
        display: block;
        width: 15%;
        float: inherit;
        right: 20px;
        border: 1px black;
        text-align: center;
        top: 15px;
        background: white;
        border-radius: 3px;
        height: 20px;
        letter-spacing: 2px;
    }

    .w100 {
        width: 100%;
    }
</style>

<body>
    <div class="upload-button up_btn">
        <span class="upload">
            </i>发布</span>
        <input class="input-file" id="sub_page" type="button" name="subpag" accept="image/*" style="position:absolute;left:0;opacity:0;width:100%;display:unset">
    </div>
    <div style="width:100%;margin: 0 auto;">
        <div class="publish-article-title">
            <div class="title-tips">标题</div>
            <input type="text" id="title" class="w100" placeholder="文章标题">
        </div>
        <div class="publish-article-content">
            <div class="title-tips">正文</div>
            <input type="hidden" id="target">
            <div class="article-content" id="content">
            </div>
            <div class="footer-btn g-image-upload-box">
                <div class="upload-button">
                    <span class="upload">
                        <i class="upload-img"></i>插入图片</span>
                    <input class="input-file" id="imageUpload" type="file" name="fileInput" accept="image/*" style="position:absolute;left:0;opacity:0;width:100%;display:unset">
                </div>
            </div>
            <!-- <div class="footer-btn g-image-upload-box">
                
            </div> -->
        </div>
    </div>
</body>
<script>
    $(sub_page).click(function () {
        var content = $('#content').getValue()
        var title = $('#title')[0].value

        $.get('/meetTWO/public/index/discussion/submit', {
            'content': content,
            'title': title,
            'id':getCookie('number')
        }, function (data) {
            if (data == 1) {
                alert("发布成功")
            } else {
                alert("发布失败")
            }
        })
    })

    $('#content').artEditor({
        imgTar: '#imageUpload',
        limitSize: 5,   // 兆
        showServer: true,
        uploadUrl: '/meetTWO/public/index/release/upImg',
        data: {},
        uploadField: 'image',
        placeholader: '',
        validHtml: ["br"],
        beforeUpload: function (imgBase64) {
            // 处理完之后，必须return图片数据   
            return imgBase64
        },
        uploadSuccess: function (res) {
            // 这里是处理返回数据业务逻辑的地方
            // `res`为服务器返回`status==200`的`response`
            // 如果这里`return <path>`将会以`<img src='path'>`的形式插入到页面
            // 如果发现`res`不符合业务逻辑
            // 比如后台告诉你这张图片不对劲
            // 麻烦返回 `false`
            // 当然如果`showServer==false`
            // 无所谓咯
            console.log("上传")
            console.log(res);
            return res;
        },
        uploadError: function (res) {
            //这里做上传失败的操作
            //也就是http返回码非200的时候
            console.log(res);
        }
    });

    function getCookie(name) {
        var strcookie = document.cookie;//获取cookie字符串
        var arrcookie = strcookie.split("; ");//分割
        //遍历匹配
        for (var i = 0; i < arrcookie.length; i++) {
            var arr = arrcookie[i].split("=");
            if (arr[0] == name) {
                return arr[1];
            }
        }
        return "";
    }
</script>

</html>